package cn.ybk.basic.config;

import cn.ybk.basic.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

// 登陆拦截器配置
@Configuration
public class LoginConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor) // 添加拦截器
            .addPathPatterns("/**")  // 添加拦截的路径
                .excludePathPatterns("/user/account/**") // 路径 接口路径/资源路径
                .excludePathPatterns("/shop/activity/**")
                .excludePathPatterns("/fastDfs/**/") // 关于图片
                .excludePathPatterns("/verifyCode/**") // 关于图片验证码
                .excludePathPatterns("/echarts/**") // 关于报表
                .excludePathPatterns("/login/**") // 关于登陆
                .excludePathPatterns("/EmailCode/**") // 关于email登陆
                .excludePathPatterns("/PhoneCode/**"); // 关于手机登陆
    }
}
